//
//  ZZCIdeaFeedbackController.m
//  ZZC-Finance
//
//  Created by mac on 2017/5/25.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "ZZCIdeaFeedbackController.h"

@interface ZZCIdeaFeedbackController ()<UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *contenTextView;
@property (weak, nonatomic) IBOutlet UITextField *contentTextField;

@end

@implementation ZZCIdeaFeedbackController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self requestLdeaFeedbackData];


}

- (void)requestLdeaFeedbackData {
   
}

- (void)textViewDidChange:(UITextView *)textView {
    if (textView.text.length > 0) {
        self.contentTextField.hidden = YES;
    }else {
        self.contentTextField.hidden = NO;
    }
}

//返回
- (IBAction)backClick {
    [self.navigationController popViewControllerAnimated:YES];
}

//提交
- (IBAction)tijiao {
    if (self.contenTextView.text == nil) {
        [SVProgressHUD showInfoWithStatus:@"内容不能为空"];
        return;
    }
    NSString *token = ZZCNSUserDefaults(@"token");
    NSDictionary *dict = @{@"token":token,@"text":self.contenTextView.text};
    NSString *sign = [ZZCRequest getSignWithDict:dict];
    sign = [NSString md5:[sign lowercaseString]];
    NSDictionary *param = @{@"timestamp":[NSString timeStr],@"sign":sign,@"token":token,@"text":self.contenTextView.text};
    [[ZZCRequest sharedNetworkTools] POST:ZZCURL_API_USERFEEDBACK parameters:param finished:^(id  _Nullable responseObject, NSError * _Nullable error) {
        if (error) {
            ZZCLog(@"失败-%@",error);
        }else {
            ZZCLog(@"成功-%@",responseObject);
            if ([responseObject[@"code"]isEqual:@(200)]) {
                [SVProgressHUD showInfoWithStatus:@"反馈成功，客服会及时处理，谢谢"];
                [self.navigationController popViewControllerAnimated:YES];
            } else {
                [SVProgressHUD showInfoWithStatus:@"操作失败，请稍后重试，谢谢"];
            }
        }
    }];
}

@end
